package com.troy.cardviews;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.CardView;
import android.widget.SeekBar;

public class CardActivity extends AppCompatActivity {
    private CardView cardView;
    private SeekBar seek1,seek2;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card);
        cardView=(CardView)findViewById(R.id.card_view);
        seek1=(SeekBar)findViewById(R.id.seek1);
        seek2=(SeekBar)findViewById(R.id.seek2);

        /*android.widget.SeekBar类*/
        /*1 最大值的设置，调用setMax()方法。
          2 现在进度值的设置，调用setProgress()方法。
          3 值变更事件处理的追加，
            调用setOnSeekBarChangeListener()方法，并传递OnSeekBarChangeListener()的实例。*/

        seek1.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                /**参数分别代表：触发操作的SeekBar，当前的进度值，是否为用户自触发*/
                if (b) {
                    cardView.setRadius(i);//圆角大小设置
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {
                /**开始拖动时触发操作*/
            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {
                /**结束拖动时触发操作*/
            }
        });

        seek2.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
            @Override
            public void onProgressChanged(SeekBar seekBar, int i, boolean b) {
                if (b) {
                    cardView.setCardElevation(i);//shadow 阴影
                }
            }

            @Override
            public void onStartTrackingTouch(SeekBar seekBar) {

            }

            @Override
            public void onStopTrackingTouch(SeekBar seekBar) {

            }
        });
    }
}
